package com.hnhcyy.goods.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hnhcyy.goods.mapper.Leibie2Mapper;
import com.hnhcyy.goods.pojo.Leibie2;
import com.hnhcyy.goods.service.Leibie2Service;

@Service
public class Leibie2ServiceImpl implements Leibie2Service {
	
	@Autowired
	private Leibie2Mapper leibie2Mapper;
	
	public static final ObjectMapper MAPPER = new ObjectMapper();
	

	@Override
	public List<Leibie2> getListBySjid(int sjid) {
		return leibie2Mapper.selectListBySjid(sjid);
	}


	@Override
	public String listGoodsCategory() {
		List<Leibie2> list = leibie2Mapper.listGoodsCategory();
		
		//转化为json字符串返回，因为admin端调用用的是原生feign，直接返回List和Mapper会提示解码错误
		String result = "";
		try {
			result = MAPPER.writeValueAsString(list);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		System.out.println("---->" + result);
		
		return result;
	}

}
